// 
//  FDScoreCardView.h
//  FiveDice
//  
//  Created by Chris Born.
//  Copyright 2007 Borngraphics. All rights reserved.
//  
//  This program is free software; you can redistribute it and/or
//  modify it under the terms of the GNU General Public License
//  as published by the Free Software Foundation; either version 2
//  of the License, or any later version.
//  
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//  
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//  
//  By contributing code you grant Chris Born and Borngraphics an
//  unlimited, non-exclusive license to your contribution.
//  
//  For support, questions, commercial use, etc...
//  E-Mail: chris <at> borngraphics <dot> com
// 

#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <UIKit/UIKit.h>
#import <UIKit/CDStructures.h>
#import <UIKit/UIView.h>
#import <UIKit/UIView-Geometry.h>
#import <UIKit/UITable.h>
#import <UIKit/UITableCell.h>
#import <UIKit/UITextLabel.h>
#import <UIKit/UITransformAnimation.h>
#import <UIKit/UIAnimator.h>
#import "WebCore/WebFontCache.h"
#import "FDDefaultsController.h"
#import "common.h"

@interface NSObject (ScoreCardDelegateMethods)

- (void)validateScoring;

@end

@interface FDScoreCardView : UIView {
	
	id	delegate;
	
	struct CGRect				_contentRect;
	struct CGRect				_offScreenRect;
	struct CGRect				_onScreenRect;
	
	UITransformAnimation	*translate;
	UIAnimator				*animator;
	
	UITable				*scoreCardTable;
	NSArray				*scoreCardTitles;
	NSMutableArray		*scoreCardEnabledFlags;
	NSMutableArray		*scoreCardScores;
	FDDefaultsController	*defaults;
	
	BOOL	newCard;
	int	_aces;
	int _twos;
	int _threes;
	int _fours;
	int _fives;
	int _sixes;
	int _threeofakind;
	int _fourofakind;
	int _fullhouse;
	int _smallstraight;
	int _largestraight;
	int _yahtzee;
	int	_chance;
	int _yahtzeechips;
	int _uppersub;
	int _upperscore;
	int _lowerscore;
	int _upperbonus;
	int _grandtotal;
	int _yahtzeeCount;
}

-(id)initWithFrame:(struct CGRect)frame;

#pragma mark Show and Hide Methods
- (void)show;
- (void)hide;

- (void)scrollToTop;
- (void)loadSavedGame;

- (void)createScoreCardTable;
- (void)scoreCardFlags;
- (int)numberOfRowsInTable: (UITable *)table;
- (UITableCell *)table:(UITable *)table cellForRow:(int)row column:(UITableColumn *)col;
- (void)reloadData;
- (void)tableRowSelected:(NSNotification *)notification;
- (void)updateScores;
- (void)clearScoreCard;
- (void)setInactiveRow:(int)row;

#pragma mark Scoring
- (void)calcUppersub;
- (void)calcUpperbonus;
- (void)calcUpperscore;
- (void)calcLowerscore;
- (void)calcYahtzeechips;
- (void)calcGrandtotal;

#pragma mark Accessors
- (BOOL)newCard;
- (void)setNewCard:(BOOL)newNewCard;
- (int)selectedRow;
- (void)setSelectedRow:(int)newRow;
- (void)clearSelection:(int)row;
- (int)yahtzeeCount;
- (void)setYahtzeeCount:(int)newYahtzeeCount;
- (NSArray *)scoreCardScores;
- (NSArray *)scoreCardSetScores;

#pragma mark Scoreing Accessors
- (int)aces;
- (void)setAces:(int)newAces;
- (int)twos;
- (void)setTwos:(int)newTwos;
- (int)threes;
- (void)setThrees:(int)newThrees;
- (int)fours;
- (void)setFours:(int)newFours;
- (int)fives;
- (void)setFives:(int)newFives;
- (int)sixes;
- (void)setSixes:(int)newSixes;
- (int)threeofakind;
- (void)setThreeofakind:(int)newThreeofakind;
- (int)fourofakind;
- (void)setFourofakind:(int)newFourofakind;
- (int)fullhouse;
- (void)setFullhouse:(int)newFullhouse;
- (int)smallstraight;
- (void)setSmallstraight:(int)newSmallstraight;
- (int)largestraight;
- (void)setLargestraight:(int)newLargestraight;
- (int)yahtzee;
- (void)setYahtzee:(int)newYahtzee;
- (int)chance;
- (void)setChance:(int)newChance;
- (int)yahtzeechips;
- (void)setYahtzeechips:(int)newYahtzeechips;
- (int)uppersub;
- (void)setUppersub:(int)newUppersub;
- (int)upperscore;
- (void)setUpperscore:(int)newUpperscore;
- (int)lowerscore;
- (void)setLowerscore:(int)newLowerscore;
- (int)upperbonus;
- (void)setUpperbonus:(int)newUpperbonus;
- (int)grandtotal;
- (void)setGrandtotal:(int)newGrandtotal;
- (void)scrollToVisible:(int)row;

#pragma mark Delegate
- (id)delegate;
- (void)setDelegate:(id)newDelegate;

#pragma mark Cleanup
-(void)dealloc;

@end